<template>
	<view class="f28">
		<view class="my-page-content ">
			<view class="my-m-title">根据退款规则</view>
			<view class="cancel-tips">
				{{chargeList[chargeStatus]}}
			</view>
			<view  class="mb20 flex-between">
				 <span>押金实付</span>
				 <span>{{$formatNumber(orderData.deposit) }}加元</span>
			</view>
			<view  class="mb20 flex-between">
				 <span>房租实付</span>
				 <span>{{$formatNumber(orderData.fee_s - orderData.deposit) }}加元</span>
			</view>
		
			<van-divider	 :margin="20" />
			<view class="count">
				<view class="mb20">
					 <span class="mr10">合计</span>
					<span>{{$formatNumber(orderData.fee_s) }}加元</span>
				</view>
				<view class="mb20">
					 <span class="mr10">违约金</span>
					  <span>{{chargeStatus ==0?0:-realRent}}加元</span>
				</view>
				<view class="mb20  f30">
					 <span class="mr10">退款金额</span>
					<span class="color-red">{{$formatNumber(orderData.fee_s - realRent ) }}加元</span>
				</view>
				
			</view>
		 
			<view class="money-tips">
				 <view>温馨提示</view>
				 <view class="tips-item">
					  <span v-html="refundInfo"></span>
				</view>
				
			</view>
			
	</view>
	</view>
	
</template>

<script>
	import moment from 'moment-timezone';
	export default {
		data() {
			return {
				orderData: this.$getStorage('orderData'),
				userInfo: '',
				serviceFee: 0,
				chargeStatus: 0,
				chargeList: ['本次取消订单将不收取任何费用','本订单享受优惠，取消订单房租不退','入住前15天内取消订单，房租不退'],
				realRent: 0,
				refundInfo: ''
			}
		}, 
		methods: {
			getConfiguration() {
				this.$http.getConfiguration().then(res => {
					res.forEach(item => {
						if (item.type == 'refund-policy') {
							this.refundInfo = item.content;
						}
					})
				});
			},
			isShowCharge() {
				this.realRent =0;
				if(Number(this.orderData.discount)) {
					this.chargeStatus = 1;
					this.realRent =  this.$formatNumber(this.orderData.rent - this.orderData.discount);
					return;
				}
				
				let nowDate = moment(new Date()).tz(this.orderData.snapshot.info.timezone).format('YYYY/MM/DD HH:mm');
				let startDate = this.orderData.start_date.replace(/-/g, "/");
				let cancelTime = new Date(nowDate).getTime() + 24 * 60 * 60 * 1000 * 15;
				if (cancelTime > new Date(startDate).getTime()) {
					this.chargeStatus = 2;
					this.realRent =  this.$formatNumber(this.orderData.rent - this.orderData.discount);
				}
				
			},
			nextStep() {
				// if(!this.radio) {
				//  this.$toast('请选择取消订单原因');
				//  return;
				// }
				// this.showDialog();
			}
		},
		mounted() {
			this.isShowCharge();
			this.getConfiguration();
		}
	}
</script>

<style scoped lang="scss">
	.cancel-tips {
		width: 100%;
		padding: 30rpx 15rpx;
		// height: 117rpx;
		background: #FFF9F1;
		box-sizing: border-box;
		margin: 30rpx auto;
		text-align: center;
		font-size: 33rpx;
		color: #EC8403;
		font-weight: 400;
	}
	.money-tips {
		width: 100%;
		font-weight: bold;
		font-size: 27rpx;
		margin-top: 100rpx;
		// height:  220rpx;
		display: inline-block;
		color: #777;
		.tips-item {
			display: flex;
			color: #999;
			margin-top: 18rpx;
			span {
				display: inline-block;
				vertical-align: top;
			}
		}
	}
	.count {
		float: right;
		text-align: right;
		// height:  220rpx;
	}
	
</style>